home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / XING Playe22067722001.psc / frmEqualizer.frm (.txt) next >
Encoding:
Visual Basic Form  |  2001-06-29  |  13.1 KB  |  468 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form frmEqualizer 
  4.    BorderStyle     =   4  'Fixed ToolWindow
  5.    Caption         =   "Equalizer"
  6.    ClientHeight    =   2310
  7.    ClientLeft      =   45
  8.    ClientTop       =   285
  9.    ClientWidth     =   4920
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   154
  14.    ScaleMode       =   3  'Pixel
  15.    ScaleWidth      =   328
  16.    ShowInTaskbar   =   0   'False
  17.    StartUpPosition =   3  'Windows Default
  18.    Begin VB.PictureBox Picture1 
  19.       Appearance      =   0  'Flat
  20.       AutoRedraw      =   -1  'True
  21.       BackColor       =   &H00000000&
  22.       BorderStyle     =   0  'None
  23.       DrawWidth       =   2
  24.       ForeColor       =   &H80000008&
  25.       Height          =   735
  26.       Left            =   90
  27.       ScaleHeight     =   49
  28.       ScaleMode       =   3  'Pixel
  29.       ScaleWidth      =   315
  30.       TabIndex        =   16
  31.       Top             =   0
  32.       Width           =   4725
  33.       Begin VB.Line linV 
  34.          BorderColor     =   &H00008000&
  35.          Index           =   6
  36.          X1              =   136
  37.          X2              =   136
  38.          Y1              =   8
  39.          Y2              =   40
  40.       End
  41.       Begin VB.Line linV 
  42.          BorderColor     =   &H00008000&
  43.          Index           =   5
  44.          X1              =   120
  45.          X2              =   120
  46.          Y1              =   8
  47.          Y2              =   40
  48.       End
  49.       Begin VB.Line linV 
  50.          BorderColor     =   &H00008000&
  51.          Index           =   4
  52.          X1              =   104
  53.          X2              =   104
  54.          Y1              =   8
  55.          Y2              =   40
  56.       End
  57.       Begin VB.Line linV 
  58.          BorderColor     =   &H00008000&
  59.          Index           =   3
  60.          X1              =   88
  61.          X2              =   88
  62.          Y1              =   8
  63.          Y2              =   40
  64.       End
  65.       Begin VB.Line linV 
  66.          BorderColor     =   &H00008000&
  67.          Index           =   2
  68.          X1              =   72
  69.          X2              =   72
  70.          Y1              =   8
  71.          Y2              =   40
  72.       End
  73.       Begin VB.Line linV 
  74.          BorderColor     =   &H00008000&
  75.          Index           =   1
  76.          X1              =   56
  77.          X2              =   56
  78.          Y1              =   8
  79.          Y2              =   40
  80.       End
  81.       Begin VB.Line linV 
  82.          BorderColor     =   &H00008000&
  83.          Index           =   0
  84.          X1              =   40
  85.          X2              =   40
  86.          Y1              =   8
  87.          Y2              =   40
  88.       End
  89.       Begin VB.Line lin0 
  90.          BorderColor     =   &H00008000&
  91.          X1              =   8
  92.          X2              =   280
  93.          Y1              =   24
  94.          Y2              =   24
  95.       End
  96.    End
  97.    Begin MSComctlLib.Slider slEqualizer 
  98.       Height          =   1095
  99.       Index           =   0
  100.       Left            =   240
  101.       TabIndex        =   0
  102.       Top             =   720
  103.       Width           =   255
  104.       _ExtentX        =   450
  105.       _ExtentY        =   1931
  106.       _Version        =   393216
  107.       Orientation     =   1
  108.       LargeChange     =   10
  109.       Min             =   -128
  110.       Max             =   127
  111.       TickFrequency   =   25
  112.    End
  113.    Begin MSComctlLib.Slider slEqualizer 
  114.       Height          =   1095
  115.       Index           =   1
  116.       Left            =   840
  117.       TabIndex        =   2
  118.       Top             =   720
  119.       Width           =   255
  120.       _ExtentX        =   450
  121.       _ExtentY        =   1931
  122.       _Version        =   393216
  123.       Orientation     =   1
  124.       LargeChange     =   10
  125.       Min             =   -128
  126.       Max             =   127
  127.       TickFrequency   =   25
  128.    End
  129.    Begin MSComctlLib.Slider slEqualizer 
  130.       Height          =   1095
  131.       Index           =   2
  132.       Left            =   1440
  133.       TabIndex        =   4
  134.       Top             =   720
  135.       Width           =   255
  136.       _ExtentX        =   450
  137.       _ExtentY        =   1931
  138.       _Version        =   393216
  139.       Orientation     =   1
  140.       LargeChange     =   10
  141.       Min             =   -128
  142.       Max             =   127
  143.       TickFrequency   =   25
  144.    End
  145.    Begin MSComctlLib.Slider slEqualizer 
  146.       Height          =   1095
  147.       Index           =   3
  148.       Left            =   2040
  149.       TabIndex        =   6
  150.       Top             =   720
  151.       Width           =   255
  152.       _ExtentX        =   450
  153.       _ExtentY        =   1931
  154.       _Version        =   393216
  155.       Orientation     =   1
  156.       LargeChange     =   10
  157.       Min             =   -128
  158.       Max             =   127
  159.       TickFrequency   =   25
  160.    End
  161.    Begin MSComctlLib.Slider slEqualizer 
  162.       Height          =   1095
  163.       Index           =   4
  164.       Left            =   2640
  165.       TabIndex        =   8
  166.       Top             =   720
  167.       Width           =   255
  168.       _ExtentX        =   450
  169.       _ExtentY        =   1931
  170.       _Version        =   393216
  171.       Orientation     =   1
  172.       LargeChange     =   10
  173.       Min             =   -128
  174.       Max             =   127
  175.       TickFrequency   =   25
  176.    End
  177.    Begin MSComctlLib.Slider slEqualizer 
  178.       Height          =   1095
  179.       Index           =   5
  180.       Left            =   3240
  181.       TabIndex        =   10
  182.       Top             =   720
  183.       Width           =   255
  184.       _ExtentX        =   450
  185.       _ExtentY        =   1931
  186.       _Version        =   393216
  187.       Orientation     =   1
  188.       LargeChange     =   10
  189.       Min             =   -128
  190.       Max             =   127
  191.       TickFrequency   =   25
  192.    End
  193.    Begin MSComctlLib.Slider slEqualizer 
  194.       Height          =   1095
  195.       Index           =   6
  196.       Left            =   3840
  197.       TabIndex        =   12
  198.       Top             =   720
  199.       Width           =   255
  200.       _ExtentX        =   450
  201.       _ExtentY        =   1931
  202.       _Version        =   393216
  203.       Orientation     =   1
  204.       LargeChange     =   10
  205.       Min             =   -128
  206.       Max             =   127
  207.       TickFrequency   =   25
  208.    End
  209.    Begin MSComctlLib.Slider slEqualizer 
  210.       Height          =   1095
  211.       Index           =   7
  212.       Left            =   4440
  213.       TabIndex        =   14
  214.       Top             =   720
  215.       Width           =   255
  216.       _ExtentX        =   450
  217.       _ExtentY        =   1931
  218.       _Version        =   393216
  219.       Orientation     =   1
  220.       LargeChange     =   10
  221.       Min             =   -128
  222.       Max             =   127
  223.       TickFrequency   =   25
  224.    End
  225.    Begin VB.Line Line1 
  226.       BorderColor     =   &H0000FF00&
  227.       BorderWidth     =   3
  228.       X1              =   8
  229.       X2              =   320
  230.       Y1              =   83
  231.       Y2              =   83
  232.    End
  233.    Begin VB.Label lblBand 
  234.       Alignment       =   2  'Center
  235.       Caption         =   "16kHz"
  236.       Height          =   255
  237.       Index           =   7
  238.       Left            =   4320
  239.       TabIndex        =   15
  240.       Top             =   1920
  241.       Width           =   495
  242.    End
  243.    Begin VB.Label lblBand 
  244.       Alignment       =   2  'Center
  245.       Caption         =   "8kHz"
  246.       Height          =   255
  247.       Index           =   6
  248.       Left            =   3720
  249.       TabIndex        =   13
  250.       Top             =   1920
  251.       Width           =   495
  252.    End
  253.    Begin VB.Label lblBand 
  254.       Alignment       =   2  'Center
  255.       Caption         =   "4kHz"
  256.       Height          =   255
  257.       Index           =   5
  258.       Left            =   3120
  259.       TabIndex        =   11
  260.       Top             =   1920
  261.       Width           =   495
  262.    End
  263.    Begin VB.Label lblBand 
  264.       Alignment       =   2  'Center
  265.       Caption         =   "2kHz"
  266.       Height          =   255
  267.       Index           =   4
  268.       Left            =   2520
  269.       TabIndex        =   9
  270.       Top             =   1920
  271.       Width           =   495
  272.    End
  273.    Begin VB.Label lblBand 
  274.       Alignment       =   2  'Center
  275.       Caption         =   "1kHz"
  276.       Height          =   255
  277.       Index           =   3
  278.       Left            =   1920
  279.       TabIndex        =   7
  280.       Top             =   1920
  281.       Width           =   495
  282.    End
  283.    Begin VB.Label lblBand 
  284.       Alignment       =   2  'Center
  285.       Caption         =   "500Hz"
  286.       Height          =   255
  287.       Index           =   2
  288.       Left            =   1320
  289.       TabIndex        =   5
  290.       Top             =   1920
  291.       Width           =   495
  292.    End
  293.    Begin VB.Label lblBand 
  294.       Alignment       =   2  'Center
  295.       Caption         =   "256Hz"
  296.       Height          =   255
  297.       Index           =   1
  298.       Left            =   720
  299.       TabIndex        =   3
  300.       Top             =   1920
  301.       Width           =   495
  302.    End
  303.    Begin VB.Label lblBand 
  304.       Alignment       =   2  'Center
  305.       Caption         =   "128Hz"
  306.       Height          =   255
  307.       Index           =   0
  308.       Left            =   120
  309.       TabIndex        =   1
  310.       Top             =   1920
  311.       Width           =   495
  312.    End
  313. Attribute VB_Name = "frmEqualizer"
  314. Attribute VB_GlobalNameSpace = False
  315. Attribute VB_Creatable = False
  316. Attribute VB_PredeclaredId = True
  317. Attribute VB_Exposed = False
  318. Option Explicit
  319. Private Sub CalculatePicture()
  320. Dim ph As Long 'picture height
  321. Dim bw As Long 'distance between two bands
  322. Dim i As Long, j As Long
  323. Dim y As Single
  324. Dim Y2 As Long, Y1 As Long
  325. Const PI = 3.1416
  326. Dim A As Single
  327. Dim sh As Single
  328. Dim phase As Single
  329. Dim c As Long
  330. ph = Picture1.Height - 1
  331. bw = Picture1.Width / 7
  332. Picture1.Cls
  333. For i = 0 To 6
  334.     Y1 = slEqualizer(i).Value
  335.     Y2 = slEqualizer(i + 1).Value
  336.     If Y1 > Y2 Then
  337.         phase = 0
  338.         A = (Y1 - Y2) / 2
  339.         sh = Y1 - A
  340.     Else
  341.         phase = PI
  342.         A = (Y2 - Y1) / 2
  343.         sh = Y1 + A
  344.     End If
  345.     For j = 0 To bw - 1
  346.         y = A * Cos(PI * j / bw + phase) + sh
  347.         Select Case Abs(y)
  348.         Case Is > 120
  349.             c = RGB(255, 0, 0)
  350.         Case Is > 110
  351.             c = RGB(192, 64, 64)
  352.         Case Is > 100
  353.             c = RGB(128, 96, 96)
  354.         Case Is > 90
  355.             c = RGB(64, 128, 128)
  356.         Case Else
  357.             c = RGB(0, 128, 128)
  358.         End Select
  359.         y = (127 - y) * ph / 255
  360.         Picture1.PSet (i * bw + j, y), c
  361.     Next j
  362. Next i
  363. End Sub
  364. Private Sub Form_Load()
  365. Dim i As Long
  366. For i = 0 To 6
  367.     linV(i).Y1 = 0
  368.     linV(i).Y2 = Picture1.Height
  369.     linV(i).X1 = (i + 1) * Picture1.Width / 8
  370.     linV(i).X2 = linV(i).X1
  371. Next i
  372. lin0.X1 = 0
  373. lin0.X2 = Picture1.ScaleWidth
  374. lin0.Y1 = (Picture1.ScaleHeight) / 2
  375. lin0.Y2 = lin0.Y1
  376. frmEqualizer.Top = frmMain.Top + frmMain.Height
  377. frmEqualizer.Left = frmMain.Left
  378. CalculatePicture
  379. End Sub
  380. Private Sub slEqualizer_Change(Index As Integer)
  381. Dim dat As Integer
  382. dat = (slEqualizer(Index).Value)
  383. 'the deal is:
  384. '   -1 is the same as 255, -2 is 254 and so on
  385. If dat < 0 Then
  386.     dat = 256 + dat
  387. End If
  388. Select Case Index
  389. Case 0
  390.     EqData.eleft(0) = dat
  391.     EqData.eright(0) = dat
  392. Case 1
  393.     EqData.eleft(1) = dat
  394.     EqData.eright(1) = dat
  395. Case 2
  396.     EqData.eleft(2) = dat
  397.     EqData.eright(2) = dat
  398.     EqData.eleft(3) = dat
  399.     EqData.eright(3) = dat
  400. Case 3
  401.     EqData.eleft(4) = dat
  402.     EqData.eright(4) = dat
  403.     EqData.eleft(5) = dat
  404.     EqData.eright(5) = dat
  405.     EqData.eleft(6) = dat
  406.     EqData.eright(6) = dat
  407. Case 4
  408.     EqData.eleft(7) = dat
  409.     EqData.eright(7) = dat
  410.     EqData.eleft(8) = dat
  411.     EqData.eright(8) = dat
  412.     EqData.eleft(9) = dat
  413.     EqData.eright(9) = dat
  414.     EqData.eleft(10) = dat
  415.     EqData.eright(10) = dat
  416. Case 5
  417.     EqData.eleft(11) = dat
  418.     EqData.eright(11) = dat
  419.     EqData.eleft(12) = dat
  420.     EqData.eright(12) = dat
  421.     EqData.eleft(13) = dat
  422.     EqData.eright(13) = dat
  423.     EqData.eleft(14) = dat
  424.     EqData.eright(14) = dat
  425.     EqData.eleft(15) = dat
  426.     EqData.eright(15) = dat
  427.     EqData.eleft(16) = dat
  428.     EqData.eright(16) = dat
  429.     EqData.eleft(17) = dat
  430.     EqData.eright(17) = dat
  431. Case 6
  432.     EqData.eleft(18) = dat
  433.     EqData.eright(18) = dat
  434.     EqData.eleft(19) = dat
  435.     EqData.eright(19) = dat
  436.     EqData.eleft(20) = dat
  437.     EqData.eright(20) = dat
  438.     EqData.eleft(21) = dat
  439.     EqData.eright(21) = dat
  440.     EqData.eleft(22) = dat
  441.     EqData.eright(22) = dat
  442.     EqData.eleft(23) = dat
  443.     EqData.eright(23) = dat
  444.     EqData.eleft(24) = dat
  445.     EqData.eright(24) = dat
  446. Case 7
  447.     EqData.eleft(25) = dat
  448.     EqData.eright(25) = dat
  449.     EqData.eleft(26) = dat
  450.     EqData.eright(26) = dat
  451.     EqData.eleft(27) = dat
  452.     EqData.eright(27) = dat
  453.     EqData.eleft(28) = dat
  454.     EqData.eright(28) = dat
  455.     EqData.eleft(29) = dat
  456.     EqData.eright(29) = dat
  457.     EqData.eleft(30) = dat
  458.     EqData.eright(30) = dat
  459.     EqData.eleft(31) = dat
  460.     EqData.eright(31) = dat
  461. End Select
  462. IssuedComm = XA_MSG_SET_CODEC_EQUALIZER
  463. SendCommand IssuedComm, agGetAddressForObject(EqData), 0
  464. 'IssuedComm = XA_MSG_GET_CODEC_EQUALIZER
  465. 'SendCommand IssuedComm, 0, 0
  466. CalculatePicture
  467. End Sub
  468.